package com.har.modules.web.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.har.common.utils.PageUtils;
import com.har.common.utils.Query;
import com.har.modules.web.dao.FinancialDao;
import com.har.modules.web.entity.FinancialEntity;
import com.har.modules.web.service.FinancialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("financialService")
public class FinancialServiceImpl extends ServiceImpl<FinancialDao, FinancialEntity> implements FinancialService {

    @Autowired
    private FinancialDao financialDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        EntityWrapper<FinancialEntity> ew=new EntityWrapper<>();
        if(params.get("productName") != null  && params.get("productName").toString().length() != 0){
            ew.like("product_name","%"+params.get("productName")+"%");
        }
        if(params.get("type") != null  && params.get("type").toString().length() != 0){
            ew.eq("type",params.get("type"));
        }
        ew.eq("status",1);
        ew.eq("product_type",5).orderBy("publish_time DESC");
        Page<FinancialEntity> page = this.selectPage(
                new Query<FinancialEntity>(params).getPage(), ew);

        return new PageUtils(page);
    }

    @Override
    public int queryTotal(Map<String, Object> params) {

        return  financialDao.queryTotal(params);
    }

}
